package reader

import (
	"encoding/json"
	"os"
	"serial-port-go/lib/utils"
	"serial-port-go/src/basic/base"
	"serial-port-go/src/basic/constant"
	"serial-port-go/src/machine/config"
)

func ReadConfigJson() {
	//获取文件路径
	wd, err := os.Getwd()
	utils.TryThrow(err)
	filePath := wd + "/" + constant.ConfigFile
	//读取文件
	file, err := os.ReadFile(filePath)
	utils.TryThrow(err)
	//转换
	properties := config.JsonProperties{}
	err = json.Unmarshal(file, &properties)
	utils.TryThrow(err)
	base.Properties = properties
}
